package gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;

public class Mouse extends JFrame {
    JTextField j1;
    JTextField j2;
    JPasswordField j3;

    public Mouse() {
        this.setLayout(null);
        this.setBounds(200, 100, 1000, 600);
        JLabel t1 = new JLabel("身份证");
        JLabel t2 = new JLabel("姓名");
        JLabel t3 = new JLabel("密码");
        this.getContentPane().setBackground(new Color(182, 194, 76, 255));
        j1 = new JTextField();

        j2 = new JTextField();
        j3 = new JPasswordField();
        t1.setBounds(350, 25, 200, 50);
        t1.setFont(new Font("宋体", Font.BOLD, 20));
        JPanel jPanel = new JPanel();
        jPanel.setBounds(85, 25, 800, 500);
        jPanel.setLayout(null);
        j1.setBounds(250, 75, 250, 30);
        this.add(jPanel);
        t2.setBounds(350, 125, 200, 50);
        t2.setFont(new Font("宋体", Font.BOLD, 20));
        j2.setBounds(250, 175, 250, 30);
        t3.setBounds(350, 225, 200, 50);
        t3.setFont(new Font("宋体", Font.BOLD, 20));
        j3.setBounds(250, 275, 250, 30);
        j1.setFont(new Font("宋体", Font.BOLD, 20));
        j2.setFont(new Font("宋体", Font.BOLD, 20));
        j3.setFont(new Font("宋体", Font.BOLD, 20));
        JButton jButton = new JButton("开卡");
        jButton.setBounds(200, 350, 150, 60);
        JButton jButton1 = new JButton("查询");
        jButton1.setBounds(400, 350, 150, 60);
        jPanel.add(jButton);
        jPanel.add(jButton1);
        jPanel.add(t3);
        jPanel.add(j3);
        jPanel.add(j2);
        jPanel.add(t2);
        jPanel.add(j1);
        jPanel.add(t1);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Writer writer = new FileWriter("F:\\data.txt");
                    writer.write(j1.getText());
                    writer.flush();
                    writer.write(j2.getText());
                    writer.flush();
                    writer.write(j3.getText());
                } catch (FileNotFoundException ex) {
                    ex.printStackTrace();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }

            }
        });
        jButton1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    InputStream in = new FileInputStream("F:\\data.txt");
                    byte[] buffer = new byte[1024];
                    int len;
                    while ((len = in.read(buffer)) != -1) {
                        System.out.println(new String(buffer, 0, len));
                    }
                    in.close();
                } catch (FileNotFoundException ex) {
                    ex.printStackTrace();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        });
    }

    public static void main(String[] args) {
        new Mouse();
    }
}

class Bank {
    private String uid;
    private String name;
    private String password;
    static long Basenum = 65402320036587L;
    private long num;

    public Bank(String uid, String name, String password) {
        this.uid = uid;
        this.name = name;
        this.password = password;
        this.num = Basenum++;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public long getNum() {
        return num;
    }

    public void setNum(long num) {
        this.num = num;
    }
}